package com.demo.springboot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.inject.Inject;

// 没有明确角色时使用
@Component("myUser")
public class User {

    @Autowired
    private UserService userService;

    // JSR 250 标准
    @Resource
    private Car car;

    // JSR 330 标准
    @Inject
    private Cat cat;

    @Override
    public String toString() {
        return "User{" +
            "userService=" + userService +
            ", car=" + car +
            ", cat=" + cat +
            '}';
    }
}
